package it.gma.torero.operator;

import it.gma.torero.expression.AbstractBooleanExpression;
import it.gma.torero.operand.Operand;
import it.gma.torero.operand.VariableBinder;
import it.gma.torero.util.Assert;

public abstract class AbstractBooleanOperator extends AbstractBooleanExpression {

	protected Operand operand1;
	protected Operand operand2;
	
	
	public AbstractBooleanOperator() {

	}

	public AbstractBooleanOperator(Operand operand1) {
		this();
		Assert.notNull(operand1);
		this.operand1 = operand1;

	}

	public AbstractBooleanOperator(Operand operand1, Operand operand2) {
		this(operand1);
		Assert.notNull(operand2);
		this.operand2 = operand2;
	}
	
	
	public boolean isConstant() {
		return false;
	}
	
	@Override
	public Object getValue() {
		return evaluate();
	}
	
	
	public void setContext(VariableBinder context) {
		if (operand1 != null) {
			operand1.setContext(context);
		}
		
		if (operand2 != null) {
			operand2.setContext(context);
		}
		
	}
	
}
